//% color="#ef784c" iconWidth=50 iconHeight=40
namespace DingdingRobot{

    //% block="初始化钉钉机器人,webhook为:[DD_WEBHOOK],secret为:[DD_SECRET]" blockType="command"
    //% DD_WEBHOOK.shadow="string" DD_WEBHOOK.defl=" "
    //% DD_SECRET.shadow="string" DD_SECRET.defl=" "
    export function initdingding(parameter: any, block: any) {
        let webhook=parameter.DD_WEBHOOK.code;
        let sceret=parameter.DD_SECRET.code;
        Generator.addImport(`from dingding import send_text`)
        Generator.addCode(`DD_WEBHOOK = ${webhook}`)
        Generator.addCode(`DD_SECRET = ${sceret}`)
    }

    //% block="发送文本[CONTENT]" blockType="command"
    //% CONTENT.shadow="string" CONTENT.defl="你好"
    export function sendtextmsg(parameter: any, block: any) {
        let content=parameter.CONTENT.code;
        Generator.addCode(`send_text(DD_WEBHOOK, DD_SECRET, ${content})`)
	}
